<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>doh.robot Editor GUI orientation and default text direction tests</title>

		<style>
			@import "../../../../util/doh/robot/robot.css";
		</style>

		<script type="text/javascript" src="../../../../dojo/dojo.js"></script>

		<script type="text/javascript">
			require([
				"doh/runner", "dojo/robotx", "dojo/dom-style", "dojo/keys",
				"dijit/tests/helpers", "dojo/domReady!"
			], function(doh, robot, domStyle, keys, helpers){

				robot.initRobot('../test_bidiEditor.html');
				var registry;
				var editor1;
				
				doh.register("setup", [
					{
						name: "wait for editors to load",
						timeout: 5000,
						runTest: helpers.waitForLoad
					},						
					function setVars(){
						registry = robot.window.require("dijit/registry");
					}
				]);

				doh.register("GUI orientation and default text direction tests", [
					{
						name: "Inherited LTR; Undefined",
						timeout: 10000,
						setUp: function(){
							editor1 = registry.byId("ed1");
						},
						runTest: function(){
							var d = new doh.Deferred();
							setTimeout(d.getTestCallback(function(){
								doh.is("ltr", domStyle.get(editor1.domNode,"direction"));
								doh.is("ltr", domStyle.get(editor1.editNode,"direction"));
							}), 3000);
							editor1.focus();
							robot.typeKeys("GUI orientation is inherited as left-to-right.",50,500);
							robot.keyPress(keys.ENTER, 100);
							robot.typeKeys("Text direction isn't defined explicitly.",50,500);							
							return d;
						}
					},
					{
						name: "Inherited RTL; Undefined",
						timeout: 10000,
						setUp: function(){
							editor1 = registry.byId("ed2");
						},
						runTest: function(){
							var d = new doh.Deferred();
							setTimeout(d.getTestCallback(function(){
								doh.is("rtl", domStyle.get(editor1.domNode,"direction"));
								doh.is("rtl", domStyle.get(editor1.editNode,"direction"));
							}), 3000);
							editor1.focus();
							robot.typeKeys("GUI orientation is inherited as right-to-left.",50,500);
							robot.keyPress(keys.ENTER, 100);
							robot.typeKeys("Text direction isn't defined explicitly.",50,500);							
							return d;
						}
					},

					{
						name: "dir=LTR; textDir=RTL",
						timeout: 10000,
						setUp: function(){
							editor1 = registry.byId("ed3");
						},
						runTest: function(){
							var d = new doh.Deferred();
							setTimeout(d.getTestCallback(function(){
								doh.is("ltr", domStyle.get(editor1.domNode,"direction"));
								doh.is("rtl", domStyle.get(editor1.editNode,"direction"));
							}), 2000);
							editor1.focus();
							robot.typeKeys("GUI orientation is set as left-to-right.",50,500);
							robot.keyPress(keys.ENTER, 100);
							robot.typeKeys("Text direction is set as right-to-left.",50,500);							
							return d;
						}
					},
					{
						name: "dir=RTL; textDir=LTR",
						timeout: 10000,
						setUp: function(){
							editor1 = registry.byId("ed4");
						},
						runTest: function(){
							var d = new doh.Deferred();
							setTimeout(d.getTestCallback(function(){
								doh.is("rtl", domStyle.get(editor1.domNode,"direction"));
								doh.is("ltr", domStyle.get(editor1.editNode,"direction"));
							}), 2000);
							editor1.focus();
							robot.typeKeys("GUI orientation is set as right-to-left.",50,500);
							robot.keyPress(keys.ENTER, 100);
							robot.typeKeys("Text direction is set as left-to-right.",50,500);							
							return d;
						}
					},
					{
						name: "Dir: LTR; TextDir: RTL (programmatic creation)",
						timeout: 10000,
						setUp: function(){
							editor1 = registry.byId("prog1");
						},
						runTest: function(){
							var d = new doh.Deferred();
							setTimeout(d.getTestCallback(function(){
								doh.is("ltr", domStyle.get(editor1.domNode,"direction"));
								doh.is("rtl", domStyle.get(editor1.editNode,"direction"));
							}), 2000);							
							editor1.focus();
							robot.typeKeys("Editor is created with left-to-right direction,",50,500);
							robot.keyPress(keys.ENTER, 100);
							robot.typeKeys("its text direction is set to right-to-left.",50,500);
							return d;
						}
					},
					{
						name: "Dir: RTL; TextDir: LTR (programmatic creation)",
						timeout: 10000,
						setUp: function(){
							editor1 = registry.byId("prog2");
						},
						runTest: function(){
							var d = new doh.Deferred();
							setTimeout(d.getTestCallback(function(){
								doh.is("rtl", domStyle.get(editor1.domNode,"direction"));
								doh.is("ltr", domStyle.get(editor1.editNode,"direction"));
							}), 2000);							
							editor1.focus();
							robot.typeKeys("Editor is created with right-to-left direction,",50,500);
							robot.keyPress(keys.ENTER, 100);
							robot.typeKeys("its text direction is set to left-to-right.",50,500);							
							return d;
						}
					} 
				]);
				doh.run();
			});
		</script>
	</head>
</html>
